package com.example.et.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.et.entity.Mechanism;
import org.apache.ibatis.annotations.*;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public interface MechanismMapper extends BaseMapper<Mechanism> {
    @Select("select info_che.id as cheid, info_che.`name` AS che, info_gong.id as gongid, info_gong.`name` AS gong, info_ban.id as banid, info_ban.name AS ban,info_gong.`administer`, info_gong.`station`from info_che INNER JOIN info_gong ON info_che.`id` = info_gong.`che_id` LEFT JOIN info_ban ON info_ban.`gong_id` = info_gong.`id`;")
    List<Mechanism> getInformation();

    @Select("select info_che.`name` AS che,info_gong.`name` AS gong,info_gong.`administer` FROM info_che INNER JOIN info_gong ON info_che.`id` = info_gong.`che_id`;")
    List<Mechanism> getCheGong();

    @Select("select info_che.`name` AS che from info_che")
    List<Mechanism> getChe();

//    @Delete("Delete from info_ban where info_ban.gong_id in (select id from info_gong where info_gong.che_id = (select id from info_che where name = #{che}) and name =  #{gong}) and info_ban.name = #{ban}")
//    int DeleteBan(@Param("che") String che,@Param("gong") String gong,@Param("ban") String ban);
    @Delete("Delete from info_ban where info_ban.gong_id in (select id from info_gong where info_gong.che_id = (select id from info_che where name = #{che}) and name =  #{gong}) and info_ban.name = #{ban}")
    int DeleteBan(Mechanism mechanism);

}
